/**
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function (height) {
  let max = 0
  // 双指针实现
  if (height.length >= 2) {


    let l = height.length
    let left = 0
    let right = l - 1
    let curArea = 0

    while (right > left) {
      curArea = (right - left) * Math.min(height[right], height[left])
      if (curArea > max) max = curArea
      height[left] >= height[right] ? right-- : left++
    }
  }
  return max

};
console.log(maxArea([2, 3, 4, 5, 18, 17, 6]));